<?php
error_reporting(E_ALL);

if(!defined('KISS_PATH')) define('KISS_PATH', dirname(__FILE__));
if(!defined('APP_PATH')) define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']));

require(KISS_PATH . '/library/CDb.php');
require(KISS_PATH . '/library/CModel.php');
require(KISS_PATH . '/library/CTableModel.php');
require(KISS_PATH . '/library/CTemplate.php');
require(KISS_PATH . '/library/CView.php');
require(KISS_PATH . '/library/CController.php');
require(KISS_PATH . '/library/CLoader.php');
CLoader::registerAutoload();

$c = isset($_GET['c']) ? trim($_GET['c']) : 'index';
$m = isset($_GET['m']) ? trim($_GET['m']) : 'index';
define('CONTROLLER_NAME', $c);
define('METHOD_NAME', $m);

$controller = 'C'.ucfirst($c).'Controller';

require(APP_PATH.'/controller/'.$controller.'.php');

$controller = new $controller();

if(!method_exists($controller, $m)) {
	echo 'Class of ', $c,' does not have the ', $m, ' method.';
	exit();
}

call_user_func(array(&$controller, $m));
